﻿using System.Diagnostics;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace PD.ShP.Code
{
    /// <summary>
    /// Class used to access resource fiels located in the SharePoint root folder (14/Resources).
    /// </summary>
    /// <remark>
    /// It requires that all webs has the same language code.
    /// </remark>
    [System.CodeDom.Compiler.GeneratedCode("TextTemplatingFileGenerator", "2.0.50727.5448")]
    [DebuggerNonUserCode]
    public static class WorkflowsResourceHelper
    {
        #region Fields

        /// <summary>
        /// Object used during initialization of the language code.
        /// </summary>
        private static readonly object LanguageCodeLock = new object();

        /// <summary>
        /// Prefix of the resource name.
        /// </summary>
        private static string resourceName = "$Resources:PD.ShP.Workflows,{0}";

        /// <summary>
        /// Name of the resource file.
        /// </summary>
        private static string defaultResource = "PD.ShP.Workflows";

        /// <summary>
        /// Language code inner field.
        /// </summary>
        private static uint? languageCodeInternal;

        #endregion

        #region Properties

        /// <summary>
        /// Gets the language code.
        /// </summary>
        public static uint LanguageCode
        {
            get
            {
                // check if initialize the language code
                if (languageCodeInternal == null)
                {
                    lock (LanguageCodeLock)
                    {
                        // double check
                        if (languageCodeInternal == null)
                        {
                            if (SPContext.Current == null || SPContext.Current.Web == null)
                            {
                                // set German as defatul
                                languageCodeInternal = 1033;
                            }
                            else
                            {
                                // set defatul laugnage of current web as default for the whole resource helper
                                languageCodeInternal = SPContext.Current.Web.Language;
                            }
                        }
                    }
                }

                return languageCodeInternal.Value;
            }
        }

        /// <summary>
        /// Gets The status name.
        /// </summary>
        public static string ReviewFeedback_ApprovedStatus
        {
            get { return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "ReviewFeedback_ApprovedStatus"), defaultResource, LanguageCode); }
        }

        /// <summary>
        /// Gets the resource string for The status name value.
        /// </summary>
        public static string ReviewFeedback_ApprovedStatus_Resource
        {
            get { return "$Resources:PD.ShP.Workflows,ReviewFeedback_ApprovedStatus"; }
        }

        /// <summary>
        /// Gets The status name.
        /// </summary>
        public static string ReviewFeedback_RejectedStatus
        {
            get { return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "ReviewFeedback_RejectedStatus"), defaultResource, LanguageCode); }
        }

        /// <summary>
        /// Gets the resource string for The status name value.
        /// </summary>
        public static string ReviewFeedback_RejectedStatus_Resource
        {
            get { return "$Resources:PD.ShP.Workflows,ReviewFeedback_RejectedStatus"; }
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        public static string TaskApproved_HistoryItem
        {
            get { return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskApproved_HistoryItem"), defaultResource, LanguageCode); }
        }

        /// <summary>
        /// Gets the resource string for Title of history item task value.
        /// </summary>
        public static string TaskApproved_HistoryItem_Resource
        {
            get { return "$Resources:PD.ShP.Workflows,TaskApproved_HistoryItem"; }
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        public static string TaskApproved_HistoryItem_EmptyComment
        {
            get { return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskApproved_HistoryItem_EmptyComment"), defaultResource, LanguageCode); }
        }

        /// <summary>
        /// Gets the resource string for Title of history item task value.
        /// </summary>
        public static string TaskApproved_HistoryItem_EmptyComment_Resource
        {
            get { return "$Resources:PD.ShP.Workflows,TaskApproved_HistoryItem_EmptyComment"; }
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        public static string TaskRejected_HistoryItem
        {
            get { return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskRejected_HistoryItem"), defaultResource, LanguageCode); }
        }

        /// <summary>
        /// Gets the resource string for Title of history item task value.
        /// </summary>
        public static string TaskRejected_HistoryItem_Resource
        {
            get { return "$Resources:PD.ShP.Workflows,TaskRejected_HistoryItem"; }
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        public static string TaskRejected_HistoryItem_EmptyComment
        {
            get { return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskRejected_HistoryItem_EmptyComment"), defaultResource, LanguageCode); }
        }

        /// <summary>
        /// Gets the resource string for Title of history item task value.
        /// </summary>
        public static string TaskRejected_HistoryItem_EmptyComment_Resource
        {
            get { return "$Resources:PD.ShP.Workflows,TaskRejected_HistoryItem_EmptyComment"; }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Gets The status name.
        /// </summary>
        /// <param name="language">The LCID of the target language.</param>
        /// <returns>
        /// The string value for the specified language.
        /// </returns>
        public static string GetReviewFeedback_ApprovedStatus(uint language)
        {
            return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "ReviewFeedback_ApprovedStatus"), defaultResource, language);
        }

        /// <summary>
        /// Gets The status name.
        /// </summary>
        /// <param name="language">The LCID of the target language.</param>
        /// <returns>
        /// The string value for the specified language.
        /// </returns>
        public static string GetReviewFeedback_RejectedStatus(uint language)
        {
            return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "ReviewFeedback_RejectedStatus"), defaultResource, language);
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        /// <param name="language">The LCID of the target language.</param>
        /// <returns>
        /// The string value for the specified language.
        /// </returns>
        public static string GetTaskApproved_HistoryItem(uint language)
        {
            return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskApproved_HistoryItem"), defaultResource, language);
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        /// <param name="language">The LCID of the target language.</param>
        /// <returns>
        /// The string value for the specified language.
        /// </returns>
        public static string GetTaskApproved_HistoryItem_EmptyComment(uint language)
        {
            return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskApproved_HistoryItem_EmptyComment"), defaultResource, language);
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        /// <param name="language">The LCID of the target language.</param>
        /// <returns>
        /// The string value for the specified language.
        /// </returns>
        public static string GetTaskRejected_HistoryItem(uint language)
        {
            return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskRejected_HistoryItem"), defaultResource, language);
        }

        /// <summary>
        /// Gets Title of history item task.
        /// </summary>
        /// <param name="language">The LCID of the target language.</param>
        /// <returns>
        /// The string value for the specified language.
        /// </returns>
        public static string GetTaskRejected_HistoryItem_EmptyComment(uint language)
        {
            return SPUtility.GetLocalizedString(string.Format(CultureInfo.InvariantCulture, resourceName, "TaskRejected_HistoryItem_EmptyComment"), defaultResource, language);
        }

        #endregion
    }
}